<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        .main {
            width: 100%;
            height: 30px;
            line-height: 30px;
            border-bottom: 1px solid #ccc;
        }
        
        .child {
            width: 100%;
            height: 100px;
            background: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <collapse></collapse>
        <collapse></collapse>
        <collapse></collapse>
        <collapse></collapse>
        <collapse></collapse>
    </div>

    <script src="./vue.js"></script>
    <!-- 可以用template来当模板 -->
    <!-- <template id="collapse">
        <div class="collapse"> -->
    <!-- <div class="main" @click="isshow = !isshow ">主面板</div>方法一 -->
    <!-- <div class="main" @click="getshow">主面板</div>
            <div class="child" v-show="isshow">子面板</div>
        </div>
    </template> -->
    <!-- 也可以用script -->
    <script id="collapse" type="text/x-template">
        <div class="collapse">
            <!-- <div class="main" @click="isshow = !isshow ">主面板</div>方法一 -->
            <div class="main" @click="getshow">主面板</div>
            <div class="child" v-show="isshow">子面板</div>
        </div>
    </script>

    <script>
        let vm = new Vue({
            el: "#app",
            components: {
                "collapse": {
                    template: "#collapse",
                    data() {
                        return {
                            isshow: false
                        }
                    },
                    methods: {
                        getshow() {
                            this.isshow = !this.isshow
                        }
                    },
                },
            }
        })
    </script>
</body>

</html>